package ee.subjects.frontend.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EventFinder {
	private HttpServletRequest request;
	private HttpServletResponse response;
	
	public EventFinder(HttpServletRequest request, HttpServletResponse response){
		this.request=request;
		this.response=response;
	}

	public String find(String mode) throws ServletException, IOException  {

		String event = "undefined";
		try {
			
			if(mode.equals("person")){
				if (request.getParameter("event") != null){
					if (request.getParameter("event").equals("insert_person")){
						event = "insert_person";
					}
					if(request.getParameter("event").equals("save_person")){
						event = "save_person";
					}
					if(request.getParameter("event").equals("edit_person")){
						event = "edit_person";
					}
					
				}
			}else if(mode.equals("something else")){
				//return something else...
			}
			
		} catch (Exception ex) {
			//TODO Logimine
			//MyLogger.Log("MenuControllerFactory.service():",ex.getMessage());
		}
		return event;
	}

}
